using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Maxleaf.EDI.Domain.EDI;

namespace Maxleaf.EDI.DataAccess.EDI.Mapping
{
    public class DBDescMap : EntityTypeConfiguration<DBDesc>
    {
        public DBDescMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Finterid, t.DBName, t.DBID, t.FDeleted });

            // Properties
            this.Property(t => t.Finterid)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.DBName)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.DBID)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.FDeleted)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("DBDesc");
            this.Property(t => t.Finterid).HasColumnName("Finterid");
            this.Property(t => t.DBName).HasColumnName("DBName");
            this.Property(t => t.DBID).HasColumnName("DBID");
            this.Property(t => t.FDeleted).HasColumnName("FDeleted");
        }
    }
}
